﻿using System;
using System.Collections.Generic;
using BruteForce.Characters;
using Microsoft.Xna.Framework;

namespace BruteForce.Screens.PlayingScreen.Map
{
    [Serializable()]
    public class MapCell
    {
        public List<int> BaseTiles = new List<int>();

        [NonSerialized]
        public Character CharacterInCell = null;

        [NonSerialized] public MapCell bpathBefore;
        [NonSerialized]
        public int bpathDist;
        [NonSerialized]
        public int pathSearchNumber;

        public bool shootable = true;

        public List<int> HeightTiles = new List<int>();

        public Vector2 Pos;
        public int InitialyTowerBelongsTo = 0; //first player = 1, second player = 2

        public bool IsTower;
        public Resources Resources;
        public List<int> TopperTiles = new List<int>();

        public MapCell(int tileID,int x,int y)
        {
            TileID = tileID;
            Walkable = true;
            SlopeMap = -1;
            Pos=new Vector2(x,y);
        }

        public bool Walkable { get; set; }
        public int SlopeMap { get; set; }
        public Color? Highlighted { get; set; }

        public int TileID
        {
            get { return BaseTiles.Count > 0 ? BaseTiles[0] : 0; }
            set
            {
                if (BaseTiles.Count > 0)
                    BaseTiles[0] = value;
                else
                    AddBaseTile(value);
            }
        }

        public void AddBaseTile(int tileID)
        {
            BaseTiles.Add(tileID);
        }

        public void AddHeightTile(int tileID)
        {
            HeightTiles.Add(tileID);
        }

        public void AddTopperTile(int tileID)
        {
            TopperTiles.Add(tileID);
        }

        public void Highlight(Color hlcolor)
        {
            Highlighted = hlcolor;
        }

        public void Lowlight()
        {
            Highlighted = null;
        }

        public bool IsHighlighted()
        {
            return Highlighted != null;
        }
    }
}